using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class tbCuaHangBUS
    {
        public static void Insert(tbCuaHang cuahang)
        {
            tbCuaHangDAL chDAL = new tbCuaHangDAL();
            chDAL.Insert(cuahang);
        }
        public static void Update(tbCuaHang cuahang)
        {
            tbCuaHangDAL chDAl = new tbCuaHangDAL();
            chDAl.Update(cuahang);
        }
        public static void Delete(int iD)
        {
            tbCuaHangDAL chDAl = new tbCuaHangDAL();
            chDAl.Delete(iD);
        }
        public static tbCuaHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbCuaHangDAL chDAL = new tbCuaHangDAL();
            return chDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCuaHangCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCuaHangDAL chDAL = new tbCuaHangDAL();
            return chDAL.Get(cri.Criter, 0, 0, tbCuaHangColumns.MaCH.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbCuaHang GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbCuaHangColumns.MaCH.ToString(), Condition.EQUAL, iD);
            tbCuaHangDAL chDAL = new tbCuaHangDAL();
            tbCuaHangCollection chCollection = chDAL.Get(cri.Criter, 0, 0, tbCuaHangColumns.MaCH.ToString(), OrderDirection.ASC.ToString(), out total);
            if (chCollection.Count > 0)
                return chCollection[0];
            return null;
        }
        public static tbCuaHangCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCuaHangDAL chDAL = new tbCuaHangDAL();
            return chDAL.Get(cri.Criter, 1, number, tbCuaHangColumns.MaCH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbCuaHangCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCuaHangDAL chDAL = new tbCuaHangDAL();
            return chDAL.Get(cri.Criter, 1, number, tbCuaHangColumns.MaCH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}